package cn.tedu.project.oa.attendanceRule.controller;

import cn.tedu.project.oa.attendanceRule.pojo.entity.ReplenishRule;
import cn.tedu.project.oa.attendanceRule.service.IReplenishRuleService;
import cn.tedu.project.oa.base.response.JsonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/oa/attendance/replenish")
@Api(tags = "09.补卡规则")
public class ReplenishRuleController {
    @Autowired
    private IReplenishRuleService replenishRuleService;

    /**
     * 查询补卡规则列表
     */
    @GetMapping("/list")
    public JsonResult list(ReplenishRule replenishRule)
    {
        List<ReplenishRule> list = replenishRuleService.selectReplenishRuleList(replenishRule);
        return JsonResult.ok(list);
    }

//    /**
//     * 导出补卡规则列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:rule:export')")
//    @Log(title = "补卡规则", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ReplenishRule replenishRule)
//    {
//        List<ReplenishRule> list = replenishRuleService.selectReplenishRuleList(replenishRule);
//        ExcelUtil<ReplenishRule> util = new ExcelUtil<ReplenishRule>(ReplenishRule.class);
//        util.exportExcel(response, list, "补卡规则数据");
//    }

    /**
     * 获取补卡规则详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getInfo(@PathVariable("id") Long id)
    {
        return JsonResult.ok(replenishRuleService.selectReplenishRuleById(id));
    }

    /**
     * 新增补卡规则
     */
    @PostMapping
    public JsonResult add( ReplenishRule replenishRule)
    {
        return JsonResult.ok(replenishRuleService.insertReplenishRule(replenishRule));
    }

    /**
     * 修改补卡规则
     */
    @PutMapping
    public JsonResult edit( ReplenishRule replenishRule)
    {
        return JsonResult.ok(replenishRuleService.updateReplenishRule(replenishRule));
    }

    /**
     * 删除补卡规则
     */
    @DeleteMapping("/{ids}")
    public JsonResult remove(@PathVariable Long[] ids)
    {
        return JsonResult.ok(replenishRuleService.deleteReplenishRuleByIds(ids));
    }
}
